//Contains the code for the directx devices and interfaces
#ifndef _H_RENDERSYSTEM__
#define _H_RENDERSYSTEM__
#define uiMAX_CHARS_PER_FRAME 256

#include<d3d10.h>
#include<d3dx10.h>

#include<windows.h>

#include<GameMath.h>

#include"FPSDisplay.h"

class RenderSystem
{
protected:
	ID3D10Device *mpD3DDevice;
	ID3D10RenderTargetView *mpRenderTargetView;
	IDXGISwapChain *mpSwapChain;

	ID3D10Texture2D *mpBackBuffer;
	ID3D10Texture2D *mpDepthStencilBuffer;
	
	RECT mScreenRect;
	HWND mWndHandle;

	Color mClearColor;

	FPSDisplay mFPS;
	bool mDisplayFPS;

	ID3DX10Font *mpFont;
	ID3DX10Sprite *mpFontSprite;
	ID3D10InfoQueue *mpMessageQueue;

	static RenderSystem *mpRenderSystem;

public:
	RenderSystem(RenderSystem &copy);
	RenderSystem() {  }
	~RenderSystem() {  }

	//Initialization Functions
	bool Initialize(RECT screenRect, HWND wndHandle);
	bool Shutdown(void);
	static bool Create(RECT screenRect, HWND wndHandle);

	bool SetClearColor(Color color);

	//Render Fucntions
	void Begin(void);
	void End(float currentTime);
	
	bool DrawTextString(int X, int Y, Color color, TCHAR* string);

	//Accessor Functions
	int GetFPS();

	ID3D10Texture2D *GetBackBuffer(void);
	ID3D10Texture2D *GetDepthStencilBuffer(void);

	RECT GetScreenRect(void);
	
	ID3D10Device* GetDevice();

	static RenderSystem* GetGraphics(void);

	//Helper Functions
	bool DumpMessageQueue(void);
	bool HasMessage(D3D10_MESSAGE);

	void ToggleFPSDisplay();
};
#endif